package net.mingsoft.msend.util;

import org.joda.time.DateTime;

import java.text.DecimalFormat;
import java.util.Random;

/**
 * @author gengfa
 * @date 22/01/26
 */
public class CodeUtil {


    private CodeUtil() {}

    public static String getCode(int length) {
        Random random = new Random(DateTime.now().getMillis());
        StringBuilder code = new StringBuilder();
        int i = length;
        for (;i > 0; i--) {
            code.append(random.nextInt(10));
        }
        return String.format("%04d", Integer.parseInt(code.toString()));
    }
}
